<!-- include style -->
<html>
<head>
<link rel="stylesheet" href="css/bootstrap.css"
	type="text/css" />
<link rel="stylesheet" href="css/bootstrap-responsive.css"
	type="text/css" />
<link rel="stylesheet" href="css/font-awesome.css"
	type="text/css" />
<script type="text/javascript" src='js/jquery-1.8.0.min.js'></script>

<script type="text/javascript" src="js/bootstrap.js"></script>


</head>
<?php
//open database
include 'config_open_db.php';
//include our awesome pagination
//class (library)
include 'ps_pagination.php';

//query all data anyway you want
//$sql = "select * from students ORDER BY stu_id DESC";
$sql = "SELECT * FROM `news`";
//execute query and get and

$rs = mysql_query( $sql ) or die('Database Error: ' . mysql_error() . ' ' . $sql );

//now, where gonna use our pagination class
//this is a significant part of our pagination
//i will explain the PS_Pagination parameters
//$conn is a variable from our config_open_db.php
//$sql is our sql statement above
//3 is the number of records retrieved per page
//4 is the number of page numbers rendered below
//null - i used null since in dont have any other
//parameters to pass (i.e. param1=valu1&param2=value2)
//you can use this if you're gonna use this class for search
//results since you will have to pass search keywords
$pager = new PS_Pagination( $conn, $sql, 5, 12, null );

//our pagination class will render new
//recordset (search results now are limited
//for pagination)
$rs = $pager->paginate();

//get retrieved rows to check if
//there are retrieved data
$num = mysql_num_rows( $rs );

if($num >= 1 ){
	//creating our table header

	echo "<table class='table table-bordered'>";
	$counter=1;
	echo "							<tr>
										<th>#</th>
										<th>Title</th>
										<th>Full Story</th>
									</tr>";
	//looping through the records retrieved
		
	
		
								$counter = 1;
				 				while($row=mysql_fetch_array($rs)){
								echo 
									"<tr>
										<td>$counter </td>
										<td>".$row['title']."</td>
										<td><a href=\"fullnews.php\">". substr($row['content'],0,20)."... </a></td>
									</tr>";
								$counter++;
								}
							?>
								</tbody>
							</table>
<?php 
}else{
	//if no records found
	echo "No records found!";
}
//page-nav class to control
//the appearance of our page
//number navigation
echo "<div class='pagination'>";
//display our page number navigation
echo $pager->renderFullNav();
echo "</div>";

?>